home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / Hydra11s.lha / HBBS / Source / Doors_System / SysopChat / Main.C < prev    next >
C/C++ Source or Header  |  1996-10-31  |  3KB  |  155 lines

  1. /*
  2.  
  3.    SysopChat Door
  4.    ==============
  5.  
  6.    functions of door.
  7.  
  8.    - doorname MUST be "SysopChat"
  9.    - display "StartChat" screen
  10.    - chat to user until DOOR_GetLine() returns IN_ENDCHAT or user loses carrier
  11.    - display "EndChat" screen
  12.  
  13. */
  14.  
  15.  
  16. #include <exec/types.h>
  17. #include <exec/memory.h>
  18. #include <dos/dos.h>
  19. #include <clib/exec_protos.h>
  20. #include <clib/dos_protos.h>
  21. #include <clib/alib_protos.h>
  22.  
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <stdio.h>
  26. #include <ctype.h>
  27. #include <time.h>
  28.  
  29.  
  30. #ifdef __SASC
  31. int CXBRK(void) { return(0); }
  32. int _CXBRK(void) { return(0); }
  33. void chkabort(void) {}
  34. #endif
  35.  
  36. #include <HBBS/ANSI_Codes.h>
  37. #include <HBBS/Defines.h>
  38. #include <HBBS/types.h>
  39. #include <HBBS/structures.h>
  40. #include <HBBS/hbbscommon_protos.h>
  41. #include <HBBS/hbbscommon_pragmas.h>
  42. #include <HBBS/Hbbsnode_protos.h>
  43. #include <HBBS/Hbbsnode_pragmas.h>
  44. #include <HBBS/release.h>
  45. char *versionstr="$VER: SysopChat "RELEASE_STR;
  46.  
  47. struct Library *HBBSCommonBase=NULL;
  48. struct Library *HBBSNodeBase=NULL;
  49.  
  50. struct BBSGlobalData *BBSGlobal=NULL;
  51. struct NodeData *N_ND=NULL;
  52. int N_NodeNum=-1;
  53.  
  54. static VOID cleanup(ULONG num)
  55. {
  56.   if (HBBSNodeBase)
  57.   {
  58.     HBBS_CleanUpDoor();
  59.     CloseLibrary (HBBSNodeBase);
  60.   }
  61.  
  62.   if (HBBSCommonBase)
  63.   {
  64.     HBBS_CleanUpCommon();
  65.     CloseLibrary (HBBSCommonBase);
  66.   }
  67.  
  68.   if (num) printf("Door Error = %d\n",num);
  69.  
  70.   exit(0);
  71. }
  72.  
  73. static VOID init(char *name)
  74. {
  75.   if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
  76.   {
  77.     cleanup(1);
  78.   }
  79.  
  80.   if (!(HBBS_InitCommon()))
  81.   {
  82.     cleanup(2);
  83.   }
  84.  
  85.   if(!(HBBSNodeBase = OpenLibrary("HBBSNode.library",0)))
  86.   {
  87.     cleanup(3);
  88.   }
  89.  
  90.   if (!(HBBS_InitDoor(N_NodeNum,name)))
  91.   {
  92.     cleanup(4);
  93.   }
  94.   SetProgramName(name);
  95. }
  96.  
  97. void DoChat( void )
  98. {
  99.   BOOL Done=FALSE;
  100.   char linewrap[BIG_STR]="";
  101.  
  102.   do
  103.   {
  104.     switch( DOOR_GetLine(GL_HISTORY|GL_EDIT|GL_DISPLAY|GL_LINEWRAP|GL_IMMEDIATE,'\0',78,0,linewrap) )
  105.     {
  106.       case IN_ENDCHAT:
  107.       case IN_LOSSCARRIER:
  108.         Done=TRUE;
  109.         break;
  110.       case IN_GOTLINE:
  111.         if (stricmp("ENDCHAT",N_ND->CurrentLine)==0) Done=TRUE;
  112.         break;
  113.     }
  114.     strcpy(linewrap,N_ND->CurrentLineWrap);
  115.   } while (!Done && N_ND->OnlineStatus==OS_ONLINE);
  116. }
  117.  
  118. void DoorMain(int argc,char *argv[])
  119. {
  120.  
  121.   DOOR_WriteText("\r\n");
  122.   DOOR_DisplaySpecialScreen("StartChat");
  123.   if (N_ND->User.Valid)
  124.   {
  125.     N_ND->Actions[ACTN_CHATTEDTOSYSOP]=ACTC_CHATTEDTOSYSOP;
  126.     DOOR_SysopText("Chatting To ");
  127.     DOOR_SysopText(N_ND->User.CallData.Handle);
  128.     DOOR_SysopText("\r\n\r\n");
  129.   }
  130.  
  131.   DoChat();
  132.  
  133.   DOOR_DisplaySpecialScreen("EndChat");
  134.  
  135. }
  136.  
  137. int main(int argc,char *argv[])
  138. {
  139.   if (sscanf(argv[1],"%d",&N_NodeNum)==0)
  140.   {
  141.     printf("Invalid/No Paramaters for door!\n");
  142.     exit (20);
  143.   }
  144.   init("SysopChat");
  145.  
  146.   if (BBSGlobal=HBBS_GimmeBBS())
  147.   {
  148.     if (N_ND=HBBS_NodeDataPtr(N_NodeNum)) // this should not fail in normal circumstances..
  149.     {
  150.       DoorMain(argc,argv);
  151.     }
  152.   }
  153.   cleanup(0);
  154. }
  155.